package engine.content;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;


public class XMLContent implements IContent<String,Document> {
	String contentType,contentBase, contentStr;
	Document domDoc;
	
	@Override
	public ContentTypes getType() {
		return ContentTypes.XML;
	}
	
	@Override
	public Document getContent() {
		return domDoc;
	}

	@Override
	public String getContentType() {
		return contentType;
		
	}

	@Override
	public void setContentType(String contentTypeStr) {
		this.contentType = contentTypeStr;
	}
	
	
	@Override
	public String getContentBase() {
		return contentBase;
		
	}

	@Override
	public void setContent(String content) throws Exception {
		this.contentStr=content;
		DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
		domDoc = docBuilder.parse(contentStr);

	}

	@Override
	public void setContentBase(String contentBaseStr) {
	}

	@Override
	public String getContentAsString() {
		return this.contentStr;
	}
	
	@Override
	public String getFileSuffix() {
		return "xml";
	}
}
